package com.sprint.controller;

import com.sprint.entities.CommonResult;
import com.sprint.entities.Payment;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
public class PaymentController {

    @Value("${server.port}")
    private String serverport;
    public static HashMap<Long, Payment> hashMap = new HashMap<Long, Payment>();
    static {
        hashMap.put(1L,new Payment(1L,"1xxxxxxxxxx1"));
        hashMap.put(2L,new Payment(2L,"2xxxxxxxxxx2"));
        hashMap.put(3L,new Payment(3L,"3xxxxxxxxxx3"));
    }

    @GetMapping(value = "/paymentSQL/{id}")
    public CommonResult<Payment> paymentSQL(@PathVariable Long id){
        Payment payment = hashMap.get(id)  ;
        CommonResult<Payment> result= new CommonResult(200
                ,"from sql,serverport="+serverport,payment);
        return result;
    }
}
